#ifndef USRAI_H
#define USRAI_H

#include "AI.h"
#include <QMap>

extern tagGame tagUsrGame;
extern ins UsrIns;
/*##########DO NOT MODIFY THE CODE ABOVE##########*/

class UsrAI:public AI
{
public:
    UsrAI(){this->id=0;}
    ~UsrAI(){}

private:
    void processData() override;
    tagInfo getInfo(){return tagUsrGame.getInfo();}
    int AddToIns(instruction ins) override
    {
        UsrIns.lock.lock();
        ins.id=UsrIns.g_id;
        UsrIns.g_id++;
        UsrIns.instructions.push(ins);
        UsrIns.lock.unlock();
        return ins.id;
    }
    void clearInsRet() override
    {
        tagUsrGame.clearInsRet();
    }
    /*##########DO NOT MODIFY THE CODE IN THE CLASS##########*/

    //bool tryBuildBuilding(int buildingType, int requiredWood, int maxCount, int reqiredBuilding,int is_settler=0);
//

//初始化函数
    void initializeFarmers();
    void initializeBuilding();
    void initializeResource();
    // void initializeShips();
    void initializeArmy();
    void initialize();
// 调试信息打印
    void stateChangeDebug();
//搜索函数 
    bool isDockBeach(int& a, int& b);
    int findResource(tagFarmer *farmer,int type);
    bool isAlreadyCovered(int x, int y);
    int findEnemyShip();

//建造函数 
    void buildHouses(int houseNum);
    void buildDock(int dockNum);
    bool isAssignBuild(int buildingType, int x, int y);
    int getBuildingSize(int buildingType);
    bool isValidLocation(int buildingType, int x, int y);
    // bool findValidLocation(int buildingType, int& x, int& y, int start_x, int start_y);


//资源采集函数


    void assignFoodAndWood(int foodFarmerNum, int woodFarmerNum, bool isAutoShipFish=false);

//市镇中心动作函数

    void centerUpgrade();
    void produceMen(int menNum);
    void produceSingleMan();
//船坞动作函数
    void createFishShip(int fishShipNum);
    void createWarShip(int warShipNum);
    void createTransportShip(int transportShipNum);
// 海军探索
    void randomNavyExplore();
    bool isAllNavyNearTarget();
    void navyAttack();
    bool isNavyWin();
    bool isNavyStuck();
    void navySuicide();
// 运输船动作
    void moveToEnemyLand();
    void transportSingleFarmer();
    void loadNearDock();
};

/*##########YOUR CODE BEGINS HERE##########*/

/*##########YOUR CODE ENDS HERE##########*/
#endif // USRAI_H
